package com.gyd.nosql;

import java.util.ArrayList;
import java.util.List;

import com.gyd.dto.Empresa;
import com.gyd.utils.Utils;
import com.mongodb.DBCursor;
import com.mongodb.DBObject;

public class Consulta {
	static List<String> value ;
	static List<String> column;
	
	public static List<Empresa> consultar(){
		Connection conect = new Connection();
		conect.conectar();
		column = new ArrayList<String>();
		value = new ArrayList<String>();

		column.add("nombre");
		value.add("Mcdonalds");
		DBCursor cursor = conect.simpleQuery("empresa", column, value);
		List<Empresa> empr = new ArrayList<Empresa>();
		while (cursor.hasNext()) {
			DBObject obj = cursor.next();
			System.out.println(obj);
			empr.add(new Empresa(Utils.Obj2Integer(obj.get("id")), (String) obj
					.get("nombre"), Utils.Obj2Double(obj.get("longitud")),
					Utils.Obj2Double(obj.get("latitud"))));
		}
		//System.out.println(empr.get(0).getNombre());
		return empr;
	}
}
